package com.frat.controller;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ControllerActivity extends Activity implements OnClickListener{
	private final String TAG = this.getClass().getSimpleName();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_controller);		
		
		// Set up the listeners
		Button button = (Button) findViewById(R.id.o_bt);
		button.setOnClickListener(this);
		button = (Button) findViewById(R.id.u_bt);
		button.setOnClickListener(this);
		button = (Button) findViewById(R.id.y_bt);
		button.setOnClickListener(this);
		button = (Button) findViewById(R.id.a_bt);
		button.setOnClickListener(this);
		button = (Button) findViewById(R.id.up_bt);
		button.setOnClickListener(this);
		button = (Button) findViewById(R.id.left_bt);
		button.setOnClickListener(this);
		button = (Button) findViewById(R.id.right_bt);
		button.setOnClickListener(this);
		button = (Button) findViewById(R.id.down_bt);
		button.setOnClickListener(this);
		button = (Button) findViewById(R.id.start_bt);
		button.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		String button;
		switch(v.getId()) {
		case R.id.o_bt:
			button = "O";
			break;
		case R.id.u_bt:
			button = "U";
			break;
		case R.id.y_bt:
			button = "Y";
			break;
		case R.id.a_bt:
			button = "A";
			break;
		case R.id.up_bt:
			button = "Up";
			break;
		case R.id.left_bt:
			button = "Left";
			break;
		case R.id.right_bt:
			button = "Right";
			break;
		case R.id.down_bt:
			button = "Down";
			break;	
		case R.id.start_bt:
			button = "Start";
			Intent intent = new Intent(this, BluetoothListActivity.class);
			startActivity(intent);
			break;
		default:
			button = "Unknown button";
			break;
		}
		
		Log.d(TAG, button + " pressed.");
	}

}
